1. Field of the Invention
The present invention relates to a data processing method and a data processing apparatus. In particular, it relates to a data processing method and a data processing apparatus preferably used in, for example, an IC (Integrated Circuit) card or the like which performs transmitting and receiving of data.
2. Description of the Related Art
An IC card (smart card) has been developed which is expected to find application in electronic money systems or security systems.
The IC card incorporates a CPU (Central Processing Unit) for carrying out various kinds of processing and a memory for storing data or the like necessary for processing in which transmitting and receiving of data is carried out in a state where the IC card is brought into contact with a predetermined reader/writer (R/W).
On the other hand, there is an IC card of a batteryless type having no battery of its own, and power is supplied to the IC card from a R/W unit.
Further, there is an IC card which performs transmitting and receiving of data between the IC card and the R/W without physical contact by using electromagnetic waves, and obtains the necessary power from the electromagnetic waves.
However, when data is transmitted and received between an IC card and a R/W without physical contact, a problem known as memory corruption occurrs if sufficient power cannot be obtained when reception of electromagnetic waves fails while accessing a memory in the IC card, and a compatibility defect occurs in the data in the memory.
Further, when data is transmitted and received by bringing the IC card into contact with the R/W, in the case where a user can freely insert or withdraw the IC card to or from the R/W, memory corruption may again occur if the IC card is withdrawn from the R/W while accessing the memory.
When data is held in units (sector in the case of MS-DOS) for storing data as in, for example, the File Allocation Table (FAT) of the MS-DOS (Microsoft-Disc Operating System) (registered trademark), if memory corruption occurs in the FAT, all the positional information of the data (file) is lost and data cannot be accessed.
Accordingly when memory corruption occurs, in the worst case, the IC card cannot be used and therefore, some countermeasure is needed against this memory corruption.
One method of dealing with this problem would be to leave data from the immediately preceding occasion and two occasions before, and update the data from two occasions before to new data so that, even if the data could not be satisfactorily updated (when the data from two occasions before is damaged), the data from the immediately preceding occasion would still remain.
When this was done however, if for example the power supply failed while the data from two occasions before was being updated, an unstable situation arose where it was impossible to read the updated data as correct or incorrect or the immediately preceding data was read.